﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="TransactionManagement.aspx.cs" Inherits="Admin_TransactionManagement" %>
<%@ Import Namespace="Money.Data" %>

<asp:Content ID="Content1" ContentPlaceHolderID="scriptCssContent" Runat="Server">
    <link href="../css/tables.css" type="text/css" rel="Stylesheet" />
    <link type="text/css" rel="Stylesheet" href="../css/form.css" />
    <script language="javascript" type="text/javascript" src="../js/common.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="titlePlaceHolder" Runat="Server">
    <asp:literal id="pageTitle" runat="server"></asp:literal>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="menuPlaceHolder" Runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="contentPlaceHolder" Runat="Server">
    <asp:scriptmanager id="ScriptManager1" runat="server">
    </asp:scriptmanager>
    <asp:label id="messageLabel" runat="server" cssclass="ErrorMessage"></asp:label><%= messageLabel.Visible == true ? "<br /><br />" : "" %>
    <fieldset id="filterSection">
        <legend><strong><%= Resources.Strings.Search %></strong></legend>
        <div id="filterSection">
            <asp:updatepanel id="UpdatePanel1" runat="server">
                <contenttemplate>
                    <div class="InputRow">
                        <label class="Label" for="<%= cbTransactionType.ClientID %>"><%= Resources.Strings.TransactionType %></label>
                        <asp:dropdownlist runat="server" id="cbTransactionType" cssclass="SingleLine" autopostback="true" onselectedindexchanged="ChangeTransactionType"></asp:dropdownlist>
                    </div>
                    <div class="InputRow">
                        <label class="Label" for="<%= cbAccount.ClientID %>"><asp:literal runat="server" id="labelAccount"></asp:literal></label>
                        <asp:dropdownlist runat="server" id="cbAccount" cssclass="SingleLine"></asp:dropdownlist>
                    </div>
                    <div class="InputRow"  runat="server" id="divAccountTo">
                        <label class="Label" for="<%= cbAccountTo.ClientID %>"><%= Resources.Strings.ToAccount %></label>
                        <asp:dropdownlist runat="server" id="cbAccountTo" cssclass="SingleLine"></asp:dropdownlist>
                    </div>
                </contenttemplate>
            </asp:updatepanel>
            <div class="InputRow">
                <label class="Label" for="<%= tbPayMan.ClientID %>"><%= Resources.Strings.PayMan %></label>
                <asp:textbox id="tbPayMan" runat="server" textmode="SingleLine" maxlength="50" cssclass="SingleLine"></asp:textbox>
            </div>
            <div class="InputRow">
                <label class="Label">&nbsp;</label>
                <asp:Button id="btSearch" runat="server" onclick="Search" text="<%$ Resources:Strings, Search %>" />
            </div>
        </div>
    </fieldset>
    <one:repeater id="repeaterTransactions" runat="server">
        <headertemplate>
            <table class="Grid">
                <thead>
                    <tr>
                        <th class="Check"><input type="checkbox" id="checkAll" onclick="choiceBehavior.doCheckAll(this.checked)" /></th>
                        <th><a href="<%= GetOrderByLink(TransactionOrderBy.Id.ToString()) %>"><%= Resources.Strings.TransactionId %></a><%= GetOrderDirectionIndicator(TransactionOrderBy.Id.ToString())%></th>
                        <th><a href="<%= GetOrderByLink(TransactionOrderBy.TransactionType.ToString()) %>"><%= Resources.Strings.TransactionType %></a><%= GetOrderDirectionIndicator(TransactionOrderBy.TransactionType.ToString())%></th>
                        <th><a href="<%= GetOrderByLink(TransactionOrderBy.Account.ToString()) %>"><%= Resources.Strings.Account %></a><%= GetOrderDirectionIndicator(TransactionOrderBy.Account.ToString())%></th>
                        <th><a href="<%= GetOrderByLink(TransactionOrderBy.Category.ToString()) %>"><%= Resources.Strings.Category %></a><%= GetOrderDirectionIndicator(TransactionOrderBy.Category.ToString())%></th>
                        <th><a href="<%= GetOrderByLink(TransactionOrderBy.Ref.ToString()) %>"><%= Resources.Strings.Ref %></a><%= GetOrderDirectionIndicator(TransactionOrderBy.Ref.ToString())%></th>
                        <th><a href="<%= GetOrderByLink(TransactionOrderBy.Class.ToString()) %>"><%= Resources.Strings.Class %></a><%= GetOrderDirectionIndicator(TransactionOrderBy.Class.ToString())%></th>
                        <th><a href="<%= GetOrderByLink(TransactionOrderBy.PayMan.ToString()) %>"><%= Resources.Strings.PayMan %></a><%= GetOrderDirectionIndicator(TransactionOrderBy.PayMan.ToString())%></th>
                        <th><a href="<%= GetOrderByLink(TransactionOrderBy.Amount.ToString()) %>"><%= Resources.Strings.Amount %></a><%= GetOrderDirectionIndicator(TransactionOrderBy.Amount.ToString())%></th>
                        <th><a href="<%= GetOrderByLink(TransactionOrderBy.CreationOn.ToString()) %>"><%= Resources.Strings.CreationOn %></a><%= GetOrderDirectionIndicator(TransactionOrderBy.CreationOn.ToString())%></th>
                        <th><%= Resources.Strings.Action %></th>
                    </tr>
                </thead>
                <tbody>
        </headertemplate>
        <itemtemplate>
                    <tr>
                        <td class="Check"><input type="checkbox" id="selectedCheckBox<%# Container.ItemIndex %>" name="selectedItems" value="<%# Eval(TransactionOrderBy.Id.ToString()) %>" onclick="choiceBehavior.checkChanged(this.checked)"/></td>
                        <td class="Number"><%# One.Web.HttpUtility.HtmlEncode(Eval(TransactionOrderBy.Id.ToString()))%></td>
                        <td><%# One.Web.HttpUtility.HtmlEncode(GetNameTransactionType(Eval(TransactionOrderBy.TransactionType.ToString())))%></td>
                        <td><%# One.Web.HttpUtility.HtmlEncode(Eval(TransactionOrderBy.Account.ToString() + ".DisplayName"))%></td>
                        <td><%# One.Web.HttpUtility.HtmlEncode(Eval(TransactionOrderBy.Category.ToString() + ".Name"))%></td>
                        <td><%# One.Web.HttpUtility.HtmlEncode(Eval(TransactionOrderBy.Ref.ToString() + ".Name"))%></td>
                        <td><%# One.Web.HttpUtility.HtmlEncode(Eval(TransactionOrderBy.Class.ToString() + ".Name"))%></td>
                        <td><%# One.Web.HttpUtility.HtmlEncode(Eval(TransactionOrderBy.PayMan.ToString()))%></td>
                        <td class="Number"><%# One.Web.HttpUtility.HtmlEncode(Eval(TransactionOrderBy.Amount.ToString()))%></td>
                        <td><%# One.Web.HttpUtility.HtmlEncode(((DateTime)Eval(TransactionOrderBy.CreationOn.ToString())).ToString(MoneyManagerConfig.DateTimeFormat))%></td>
						<td>
						    <a href="EditTransaction.aspx?transactionId=<%# Eval(TransactionOrderBy.Id.ToString()) %>"><%= Resources.Strings.Edit %></a>
						</td>
                    </tr>
        </itemtemplate>
        <nonetemplate>
                    <tr>
                        <td colspan="11"><%= Resources.Strings.NoItem %></td>
                    </tr>
        </nonetemplate>
        <footertemplate>
                </tbody>
            </table>
        </footertemplate>
    </one:repeater>
    <div class="Pagination">
        <one:pager id="pager" runat="server" parameter="Page" pagesize="5"></one:pager> 
    </div>
    <div class="ActionRow">
        <asp:button runat="server" id="deleteButton" text="<%$ Resources:Strings,Delete %>" onclick="DeleteTransactions" />      
        <input type="button" value="<%= Resources.Strings.Add %>" onclick="window.location = 'EditTransaction.aspx';" />
        <input type="button" value="<%= Resources.Strings.AddFromMemorizedTransaction %>" onclick="window.location = 'ChooseMemorizedTransaction.aspx';" />
    </div>
    <script language="javascript" type="text/javascript">
        choiceBehavior.totalItems = <%= listTransactions == null ? 0 : listTransactions.Count%>;
        choiceBehavior.btnActions = new Array();
        choiceBehavior.btnActions[0] = getControl('<%= deleteButton.ClientID%>');
        choiceBehavior.checkAll = getControl('checkAll');
        choiceBehavior.init();
    </script>    
</asp:Content>

